﻿using System;

namespace OConf.Common
{
    public class ManagerUnit
    {
        /// <summary>
        /// 获取当前用户ID
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentID()
        {
            return HttpUnit.Current?.User?.FindFirst("ID")?.Value ?? "";
        }

        /// <summary>
        /// 获取当前用户名称
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentName()
        {
            return HttpUnit.Current?.User?.FindFirst("UserName")?.Value ?? "";
        }

        /// <summary>
        /// 获取当前用户角色
        /// </summary>
        /// <returns></returns>
        public static int GetCurrentRoleType()
        {
            string roleType = HttpUnit.Current?.User?.FindFirst("RoleType")?.Value ?? "-1";
            return Convert.ToInt32(roleType);
        }
    }
}
